package com.drcoffee.drcoffeemall.controller;

import com.drcoffee.drcoffeemall.entry.AfterSale;
import com.drcoffee.drcoffeemall.entry.Result;
import com.drcoffee.drcoffeemall.service.AfterSaleService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/afterSale")
public class AfterSaleController {

    final
    AfterSaleService afterSaleService;

    public AfterSaleController(AfterSaleService afterSaleService) {
        this.afterSaleService = afterSaleService;
    }

    /*
     * 添加售后申请
     * */
    @PostMapping("/addAfterSale")
    public Result addAfterSale(@RequestHeader String Token, @RequestBody AfterSale afterSale) {
        return afterSaleService.addAfterSale(Token, afterSale);
    }

    /*
     * 根据账号查询售后记录
     * */
    @PostMapping("/getAfterSaleList")
    public ResponseEntity<Object> getAfterSaleList(@RequestHeader String Token, @RequestBody Map<String, Object> paramMap) {
        return afterSaleService.getAfterSaleList(Token, paramMap);
    }

    @GetMapping("/getNotYetAfterSaleParts")
    public Result getNotYetAfterSaleParts(@RequestParam String order_code) {
        return afterSaleService.getNotYetAfterSaleParts(order_code);
    }

    /*
     * 设置快递单号
     * */
    @GetMapping("setTransportByCode")
    public Result setTransportByCode(@RequestParam String code, @RequestParam String transpor_code, @RequestParam Integer type) {
        return afterSaleService.setTransportByCode(code, transpor_code, type);
    }


    /*
     * 根据id查询售后单
     * */
    @GetMapping("getAfterSaleByCode")
    public Result getAfterSaleByCode(@RequestParam String code) {
        return afterSaleService.getAfterSaleByCode(code);
    }

    /*
     * 撤销售后申请
     * */
    @GetMapping("cancelAfterSale")
    public Result cancelAfterSale(@RequestParam String code) {
        return afterSaleService.cancelAfterSale(code);
    }

    @GetMapping("/reissueReceiveGoods")
    public Result reissueReceiveGoods(@RequestParam String code) {
        return afterSaleService.reissueReceiveGoods(code);
    }

}
